<?php

namespace App\Admin\Forms;

use Dcat\Admin\Widgets\Form;

class Setting extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        admin_setting($input);

        return $this
				->response()
				->success('保存成功')
				->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->switch('isarticle')->label('是否开启资讯');
        $this->switch('isopengame')->label('是否开启游戏');
        $this->switch('isOpenLottery')->label('是否开启抽奖');
        $this->switch('isShortVideo')->label('短视频');
        $this->switch('isGg')->label('公告是否显示');
        $this->text('notice_content')->label('公告内容');
        $this->url('lotteryUrl')->label('抽奖网址');
        $this->text('mediaId')->label('mediaId');
        $this->text('appSecret')->label('appSecret');
        $this->text('appSecret')->label('appSecret');
        $this->text('clock_start')->label('clock_start');

//        $this->text('slug')->required()->help('提交后不可更改')->placeholder('请输入key名称')->label('key');
//        $this->text('value')->required();
//        $this->text('comment');
    }

    /**
     * The data of the form.
     *
     * @return array
     */
    public function default()
    {
        return [
            'isarticle'  => admin_setting('isarticle',0),
            'isShortVideo'  => admin_setting('isShortVideo',0),
            'isopengame'  => admin_setting('isopengame',0),
            'isOpenLottery'  => admin_setting('isOpenLottery',0),
            'lotteryUrl' => admin_setting('lotteryUrl',''),
            'mediaId' => admin_setting('mediaId',''),
            'appSecret' => admin_setting('appSecret',''),
            'isGg' => admin_setting('isGg',0),
            'notice_content' => admin_setting('notice_content',''),
            'clock_start' => admin_setting('clock_start',''),
        ];
    }
}
